<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

<div id="app">
  <div >
      <p v-for="(val,key) in obj">{{val}}</p>
  </div>
  <div >
      <p v-for="(item,index) in arr">{{item}}</p>
  </div>
  <button @click="action()">点击</button>
</div>


<script>
  var vm = new Vue({
    el: '#app',
    methods: {
      action() {
        // this.obj.like = '苹果';//无用
        this.$set(this.obj,'like','苹果');//有用
        // this.arr[4] = 4;//无用
        // this.arr.push(4)//有用
        this.$set(this.arr,4,4);//有用
      }
    },
    data: {
      obj: {
        name:'ssx',
        age:18
      },
      arr:[1,2,3]
    }
  });
</script>



</body>
</html>
